# coding:utf-8

import time
import datetime
# 生成时间戳函数
timest = time.time()
print(timest)
# 获取本地时间函数
local = time.localtime()
print(local)
# 查看localtime属性字段
print(local.tm_year,local.tm_mon,local.tm_mday)
# 暂停函数
# time.sleep(3)

# time => str
print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()))
# str => time
print(time.strptime('2024-04-02','%Y-%m-%d'))

# datetime 生成时间戳函数
# 需要将datetime对象转为timestamp
now = datetime.datetime.now()
print(datetime.datetime.timestamp(now))
# datetime: timestamp => datetime
print(datetime.datetime.fromtimestamp(timest))

